package com.xingzhi.shortvideosharingplatform.controller;

import com.xingzhi.shortvideosharingplatform.common.Result;
import com.xingzhi.shortvideosharingplatform.model.Video;
import com.xingzhi.shortvideosharingplatform.service.VideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/v1/videos")
public class VideoZController {

    @Autowired
    private VideoService videoService;

    /**
     * 根据ID获取视频信息
     * @param id 视频ID
     * @return 视频信息
     */
    @GetMapping("/{id}")
    public Result<Video> getVideoById(@PathVariable Long id) {
        log.info("获取视频信息，id：{}", id);
        Video video = videoService.getById(id);
        if (video == null) {
            return Result.error(404, "视频不存在");
        }
        return Result.success(video, "获取视频信息成功");
    }
} 